#! /bin/bash
# chkconfig: 2345 99 99

#启动
nginx_start(){
	if [ -f /usr/local/nginx/logs/nginx.pid ];then
		echo "nginx is running"
	else
		/usr/local/nginx/sbin/nginx  &>/dev/null
	fi
}
#停止
nginx_stop(){
	if [ -f /usr/local/nginx/logs/nginx.pid ];then
		/usr/local/nginx/sbin/nginx -s stop &>/dev/null
	else
		echo "nginx is not running"
	fi
}
#查询服务状态
nginx_status(){
	if [ -f /usr/local/nginx/logs/nginx.pid ];then
        echo "nginx is running"
    else
        echo "nginx is not running"
    fi
}

case $1 in
start)
	nginx_start
;;
stop)
	nginx_stop
;;
restart)
	nginx_stop
	nginx_start
;;
status)
	nginx_status
;;
*)
	echo "$0 <start;stop;restart;status>"
;;
esac



